﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Trigger_show_room1 : MonoBehaviour
{
    public GameObject contrelBall;
    public GameObject contrelObj;
    public bool hasDamage = false;
    //bool isAfter = false;
    float timer = 0;
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    private void OnTriggerEnter(Collider other)
    {
        if (other.tag.Equals("Player"))
        {
            if (!contrelObj.GetComponent<Room1_Contrel>().isPass)
            {
                contrelBall.GetComponent<BindShowText>().setShowText("根据“红黄绿”的顺序触发按钮。\n没跟你开玩笑，乱踩后果自负！");
                contrelBall.GetComponent<BindShowText>().showShowText();
            }
        }
    }

    private void OnTriggerExit(Collider other)
    {
        if (other.tag.Equals("Player"))
        {
            contrelObj.GetComponent<Room1_Contrel>().canPrint = false;
        }
    }

    private void OnTriggerStay(Collider other)
    {
        if(other.tag.Equals("Player")&&(timer+=Time.deltaTime)>0.5&&hasDamage)
        {
            other.GetComponent<Tools>().hp -= 1;
            timer = 0;
            contrelBall.GetComponent<BindShowText>().setShowText("你这是自作自受！");
            contrelBall.GetComponent<BindShowText>().showShowText();
        }
    }

    
}
